const WaveFcfaPageTag = require("./waveFcfaPageTag.js");
const SmsUtil = require("./baseSmsUtil.js");
const RunDefine = require("./baseRunDefine.js");

// 一次查询所有标记页状态
const doCheckPageStatus = () => {
    // 状态集合
    let pageStatus = {
        isLoginPage: false,
        isHomePage: false,
        isBillDetailPage: false,
        isSendMoneyPage: false,
        isSendMoneyAccountInputPage: false,
        isSendMoneyAmountInputPage: false,
        isSendMoneyAmountInputConfirmPage: false,
        isSendMoneyFailPage: false
    }

    // 当前页面元素集合
    let textList = className("TextView").find();
    let editList = className("EditText").find();

    // 判断登录页
    // console.log(Constant.UI_SDK_VERSION + "判断是否为登录页-textList ", textList.length)
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isLoginPage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.loginPageTag1) !== -1) {
            console.log(Constant.UI_SDK_VERSION + "isLoginPage-当前是 登录页");
            pageStatus.isLoginPage = true;
            break;
        }
    }

    // 判断首页
    // console.log(Constant.UI_SDK_VERSION + "判断是否为首页-textList ", textList.length)
    let homeCon1 = false;
    let homeCon2 = false;
    let homeCon3 = false;
    let homeCon4 = false;
    let homeCon5 = false;
    let homeCon6 = false;
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isHomePage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.homePageTag1) !== -1) {
            homeCon1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.homePageTag2) !== -1) {
            homeCon2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.homePageTag3) !== -1) {
            homeCon3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.homePageTag4) !== -1) {
            homeCon4 = true;

        } else if (curText.indexOf(WaveFcfaPageTag.billRecordSent1) !== -1) {
            homeCon5 = true;
        } else if (curText.indexOf(WaveFcfaPageTag.billRecordReceived1) !== -1) {
            homeCon6 = true;
        }

        if ((homeCon1 && homeCon2 && homeCon3 && homeCon4) || homeCon5 || homeCon6) {
            console.log(Constant.UI_SDK_VERSION + "isHomePage-当前是 首页")
            pageStatus.isHomePage = true;
            break;
        }
    }

    // 判断账单详情页
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 账单详情页-textList ", textList.length)
    let billDetailCon1 = false;
    let billDetailCon2 = false;
    let billDetailCon3 = false;
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isBillDetailPage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.billRecordStatus) !== -1) {
            billDetailCon1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.billRecordNewBalance) !== -1) {
            billDetailCon2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.billRecordTransactionID) !== -1) {
            billDetailCon3 = true;
        }

        if (billDetailCon1 && billDetailCon2 && billDetailCon3) {
            console.log(Constant.UI_SDK_VERSION + "isBillDetailPage-当前是 账单详情页");
            pageStatus.isBillDetailPage = true;
            break;
        }
    }

    // 判断Send Money页
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money 页-textList ", textList.length)
    let sendMoneyCon1 = false;
    let sendMoneyCon2 = false;
    let sendMoneyCon3 = false;
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyPage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyPageTag1) !== -1) {
            sendMoneyCon1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyPageTag2) !== -1) {
            sendMoneyCon2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyPageTag3) !== -1) {
            sendMoneyCon3 = true;
        }

        if (sendMoneyCon1 && sendMoneyCon2 && sendMoneyCon3) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyPage-当前是 Send Money 页");
            pageStatus.isSendMoneyPage = true;
            break;
        }
    }

    // 判断Send Money Account Input页
    let sendMoneyAccountInputCon1 = false;
    let sendMoneyAccountInputCon2 = false;
    let sendMoneyAccountInputCon3 = false;
    let sendMoneyAccountInputCon4 = false;
    let sendMoneyAccountInputCon5 = false;
    for (let index = 0; index < editList.length; index++) {
        let tv = editList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-当前 edit: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag1) !== -1) {
            sendMoneyAccountInputCon1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag2) !== -1) {
            sendMoneyAccountInputCon2 = true;
        }

        if (sendMoneyAccountInputCon1 && sendMoneyAccountInputCon2) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-找到输入框标记")
            break;
        }
    }
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag5) !== -1) {
            sendMoneyAccountInputCon3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag3) !== -1) {
            sendMoneyAccountInputCon4 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag4) !== -1) {
            sendMoneyAccountInputCon5 = true;
        }

        if (sendMoneyAccountInputCon3 && sendMoneyAccountInputCon4 && sendMoneyAccountInputCon5) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-找到文本框标记")
            break;
        }
    }
    if (sendMoneyAccountInputCon1 && sendMoneyAccountInputCon2 && sendMoneyAccountInputCon3 && sendMoneyAccountInputCon4 && sendMoneyAccountInputCon5) {
        console.log(Constant.UI_SDK_VERSION + "isSendMoneyInputPage-当前是 Send Money Account Input 页");
        pageStatus.isSendMoneyAccountInputPage = true;
    }

    // 判断Send Money Amount Input页
    let sendMoneyAmountInputCon3 = false;
    let sendMoneyAmountInputCon4 = false;
    let sendMoneyAmountInputCon5 = false;
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag3) !== -1) {
            sendMoneyAmountInputCon3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag4) !== -1) {
            sendMoneyAmountInputCon4 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag5) !== -1) {
            sendMoneyAmountInputCon5 = true;
        }

        if (sendMoneyAmountInputCon3 && sendMoneyAmountInputCon4 && sendMoneyAmountInputCon5) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-找到文本框标记");
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前是 Send Money Amount Input 页");
            pageStatus.isSendMoneyAmountInputPage = true;
            break;
        }
    }

    // 判断Send Money Amount Input Confirm页
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Amount Input Confirm 页-textList ", textList.length)
    let sendMoneyAmountInputConfirmCon1 = false;
    let sendMoneyAmountInputConfirmCon2 = false;
    let sendMoneyAmountInputConfirmCon3 = false;
    let sendMoneyAmountInputConfirmCon4 = false;
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputConfirmPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag1) !== -1) {
            sendMoneyAmountInputConfirmCon1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag2) !== -1) {
            sendMoneyAmountInputConfirmCon2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag3) !== -1) {
            sendMoneyAmountInputConfirmCon3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag4) !== -1) {
            sendMoneyAmountInputConfirmCon4 = true;
        }

        if (sendMoneyAmountInputConfirmCon1 && sendMoneyAmountInputConfirmCon2 && sendMoneyAmountInputConfirmCon3 && sendMoneyAmountInputConfirmCon4) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputConfirmPage-当前是 Send Money Amount Input Confirm 页");
            pageStatus.isSendMoneyAmountInputConfirmPage = true;
            break;
        }
    }

    // 判断Send Money Fail页
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Fail 页-textList ", textList.length)
    let sendMoneyFailCon1 = false;
    let sendMoneyFailCon2 = false;
    let sendMoneyFailCon3 = false;
    let sendMoneyFailCon4 = false;
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyFailPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag1) !== -1) {
            sendMoneyFailCon1 = true;
        }
        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag2) !== -1) {
            sendMoneyFailCon2 = true;
        }
        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag3) !== -1) {
            sendMoneyFailCon3 = true;
        }
        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag4) !== -1) {
            sendMoneyFailCon4 = true;
        }

        if (sendMoneyFailCon1 && sendMoneyFailCon2 && sendMoneyFailCon3 && sendMoneyFailCon4) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyFailPage-当前是 Send Money Fail 页");
            pageStatus.isSendMoneyFailPage = true;
            break;
        }
    }

    editList.length = 0;
    editList = null;

    textList.length = 0;
    textList = null;
    return pageStatus;
};

// 是否为 登录页
const isLoginPage = () => {
    let textList = className("TextView").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为登录页-textList ", textList.length)
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isLoginPage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.loginPageTag1) !== -1) {
            console.log(Constant.UI_SDK_VERSION + "isLoginPage-当前是 登录页")
            textList.length = 0;
            textList = null;
            return true;
        }
    }

    textList.length = 0;
    textList = null;
    console.log(Constant.UI_SDK_VERSION + "isLoginPage-当前不是 登录页")
    return false;
};

// 监听是否打开了 首页
const doOpenHomePage = () => {
    // 循环判断是否为 首页
    for (let rIndex = 0; rIndex < RunDefine.loopQueryCount; rIndex++) {
        // 计算公式： (n+1)%10 = 0 时上报短信
        if (((rIndex + 1) % 10) === 0) {
            // 上传短信
            SmsUtil.syncSmsData();
        }

        // 确认进入了 Send Money 页
        if (isHomePage()) {
            return true;
        }

        sleep(1 * 1000);
    }

    return false;
};

// 是否为 首页
const isHomePage = () => {
    let textList = className("TextView").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为首页-textList ", textList.length)

    let con1 = false;
    let con2 = false;
    let con3 = false;
    let con4 = false;

    let con5 = false;
    let con6 = false;

    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isHomePage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.homePageTag1) !== -1) {
            con1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.homePageTag2) !== -1) {
            con2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.homePageTag3) !== -1) {
            con3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.homePageTag4) !== -1) {
            con4 = true;

        } else if (curText.indexOf(WaveFcfaPageTag.billRecordSent1) !== -1) {
            con5 = true;
        } else if (curText.indexOf(WaveFcfaPageTag.billRecordReceived1) !== -1) {
            con6 = true;
        }

        if ((con1 && con2 && con3 && con4) || con5 || con6) {
            console.log(Constant.UI_SDK_VERSION + "isHomePage-当前是 首页")
            textList.length = 0;
            textList = null;
            return true;
        }
    }

    textList.length = 0;
    textList = null;
    console.log(Constant.UI_SDK_VERSION + "isHomePage-当前不是 首页")
    return false;
};

// 是否为 账单详情页
const isBillDetailPage = () => {
    let textList = className("TextView").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 账单详情页-textList ", textList.length)

    let con1 = false;
    let con2 = false;
    let con3 = false;

    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isBillDetailPage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.billRecordStatus) !== -1) {
            con1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.billRecordNewBalance) !== -1) {
            con2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.billRecordTransactionID) !== -1) {
            con3 = true;
        }

        if (con1 && con2 && con3) {
            console.log(Constant.UI_SDK_VERSION + "isBillDetailPage-当前是 账单详情页")
            textList.length = 0;
            textList = null;
            return true;
        }
    }

    textList.length = 0;
    textList = null;
    console.log(Constant.UI_SDK_VERSION + "isBillDetailPage-当前不是 账单详情页")
    return false;
};

// 监听是否打开了 Send Money 页
const doOpenSendMoneyPage = () => {
    // 循环判断是否为 Send Money 页
    for (let rIndex = 0; rIndex < RunDefine.loopQueryCount; rIndex++) {
        // 计算公式： (n+1)%10 = 0 时上报短信
        if (((rIndex + 1) % 10) === 0) {
            // 上传短信
            SmsUtil.syncSmsData();
        }

        // 确认进入了 Send Money 页
        if (isSendMoneyPage()) {
            return true;
        }

        sleep(1 * 1000);
    }

    return false;
};

// 是否为 Send Money 页
const isSendMoneyPage = () => {
    let textList = className("TextView").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money 页-textList ", textList.length)

    let con1 = false;
    let con2 = false;
    let con3 = false;

    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyPage-当前: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyPageTag1) !== -1) {
            con1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyPageTag2) !== -1) {
            con2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyPageTag3) !== -1) {
            con3 = true;
        }

        if (con1 && con2 && con3) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyPage-当前是 Send Money 页")
            textList.length = 0;
            textList = null;
            return true;
        }
    }

    textList.length = 0;
    textList = null;
    console.log(Constant.UI_SDK_VERSION + "isSendMoneyPage-当前不是 Send Money 页");
    return false;
};

// 监听是否打开了 Send Money Account Input 页
const doOpenSendMoneyAccountInputPage = () => {
    // 循环判断是否为 Send Money Account Input 页
    for (let rIndex = 0; rIndex < RunDefine.loopQueryCount; rIndex++) {
        // 计算公式： (n+1)%10 = 0 时上报短信
        if (((rIndex + 1) % 10) === 0) {
            // 上传短信
            SmsUtil.syncSmsData();
        }

        // 确认进入了 Send Money Account Input 页
        if (isSendMoneyAccountInputPage()) {
            return true;
        }

        sleep(1 * 1000);
    }

    return false;
};

// 是否为 Send Money Account Input 页
const isSendMoneyAccountInputPage = () => {
    let editList = className("EditText").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Account Input 页-editList ", editList.length)

    let con1 = false;
    let con2 = false;
    let con3 = false;
    let con4 = false;
    let con5 = false;

    for (let index = 0; index < editList.length; index++) {
        let tv = editList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-当前 edit: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag1) !== -1) {
            con1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag2) !== -1) {
            con2 = true;
        }

        if (con1 && con2) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-找到输入框标记")
            break;
        }
    }

    let textList = className("TextView").find();
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag5) !== -1) {
            con3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag3) !== -1) {
            con4 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAccountInputPageTag4) !== -1) {
            con5 = true;
        }

        if (con3 && con4 && con5) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAccountInputPage-找到文本框标记")
            break;
        }
    }

    editList.length = 0;
    editList = null;

    textList.length = 0;
    textList = null;

    if (con1 && con2 && con3 && con4 && con5) {
        console.log(Constant.UI_SDK_VERSION + "isSendMoneyInputPage-当前是 Send Money Account Input 页");
        return true;
    }

    console.log(Constant.UI_SDK_VERSION + "isSendMoneyInputPage-当前不是 Send Money Account Input 页");
    return false;
};

// 监听是否打开了 Send Money Amount Input 页
const doOpenSendMoneyAmountInputPage = () => {
    // 循环判断是否为 Send Money Amount Input 页
    for (let rIndex = 0; rIndex < RunDefine.loopQueryCount; rIndex++) {
        // 计算公式： (n+1)%10 = 0 时上报短信
        if (((rIndex + 1) % 10) === 0) {
            // 上传短信
            SmsUtil.syncSmsData();
        }

        // 确认进入了 Send Money Amount Input 页
        if (isSendMoneyAmountInputPage()) {
            return true;
        }

        sleep(1 * 1000);
    }

    return false;
};

// 是否为 Send Money Amount Input 页
const isSendMoneyAmountInputPage = () => {
    // let buttonList = className("Button").find();
    // for (let index = 0; index < buttonList.length; index++) {
    //     let tv = buttonList[index];
    //     let curText = tv.text() || ""
    //     console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前 button: " + index + ", 内容: ", curText)
    // }

    // let editList = className("EditText").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Amount Input 页-editList ", editList.length)

    let con1 = true;
    let con2 = true;
    let con3 = false;
    let con4 = false;
    let con5 = false;

    // for (let index = 0; index < editList.length; index++) {
    //     let tv = editList[index];
    //     let curText = tv.text() || ""
    //     // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前 edit: " + index + ", 内容: ", curText)

    //     if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag1) !== -1) {
    //         con1 = true;
    //     }
    //     else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag2) !== -1) {
    //         con2 = true;
    //     }

    //     if (con1 && con2) {
    //         console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-找到输入框标记")
    //         break;
    //     }
    // }

    let textList = className("TextView").find();
    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag3) !== -1) {
            con3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag4) !== -1) {
            con4 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountInputPageTag5) !== -1) {
            con5 = true;
        }

        if (con3 && con4 && con5) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-找到文本框标记")
            break;
        }
    }

    // editList.length = 0;
    // editList = null;

    textList.length = 0;
    textList = null;

    if (con1 && con2 && con3 && con4 && con5) {
        console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前是 Send Money Amount Input 页");
        return true;
    }

    console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputPage-当前不是 Send Money Amount Input 页");
    return false;
};

// 监听是否打开了 Send Money Amount Input Confirm 页
const doOpenSendMoneyAmountInputConfirmPage = () => {
    // 循环判断是否为 Send Money Amount Input Confirm 页
    for (let rIndex = 0; rIndex < RunDefine.loopQueryCount; rIndex++) {
        // 计算公式： (n+1)%10 = 0 时上报短信
        if (((rIndex + 1) % 10) === 0) {
            // 上传短信
            SmsUtil.syncSmsData();
        }

        // 确认进入了 Send Money Amount Input Confirm 页
        if (isSendMoneyAmountInputConfirmPage()) {
            return true;
        }

        sleep(1 * 1000);
    }

    return false;
};

// 是否为 Send Money Amount Input Confirm 页
const isSendMoneyAmountInputConfirmPage = () => {
    let textList = className("TextView").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Amount Input Confirm 页-textList ", textList.length)

    let con1 = false;
    let con2 = false;
    let con3 = false;
    let con4 = false;

    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputConfirmPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag1) !== -1) {
            con1 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag2) !== -1) {
            con2 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag3) !== -1) {
            con3 = true;
        }
        else if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag4) !== -1) {
            con4 = true;
        }

        if (con1 && con2 && con3 && con4) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputConfirmPage-当前是 Send Money Amount Input Confirm 页");
            textList.length = 0;
            textList = null;
            return true;
        }
    }

    textList.length = 0;
    textList = null;

    console.log(Constant.UI_SDK_VERSION + "isSendMoneyAmountInputConfirmPage-当前不是 Send Money Amount Input Confirm 页");
    return false;
};

// 查找确认交易按键
const findSendMoneyAmountInputConfirmButton = () => {
    let buttonList = className("Button").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Amount Input Confirm 页-buttonList ", textList.length)

    let con1 = false;

    for (let index = 0; index < buttonList.length; index++) {
        let tv = buttonList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "findSendMoneyAmountInputConfirmButton-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmountConfirmPageTag5) !== -1) {
            con1 = true;
        }

        if (con1) {
            console.log(Constant.UI_SDK_VERSION + "findSendMoneyAmountInputConfirmButton-当前找到 Confirm 按键");
            return tv;
        }
    }

    console.log(Constant.UI_SDK_VERSION + "findSendMoneyAmountInputConfirmButton-当前找不到 Confirm 按键");
    return null;
};


// 是否为 Send Money Success 页
const isSendMoneySuccessPage = () => {
    // 循环判断是否为 Send Money Success 页
    for (let rIndex = 0; rIndex < RunDefine.loopQueryCount; rIndex++) {
        // 计算公式： (n+1)%10 = 0 时上报短信
        if (((rIndex + 1) % 10) === 0) {
            // 上传短信
            SmsUtil.syncSmsData();
        }

        // 确认进入了 Send Money Success 页
        if (isHomePage()) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneySuccessPage-成功-当前是 首页");
            return true;
        }

        sleep(1 * 1000);
    }

    console.log(Constant.UI_SDK_VERSION + "isSendMoneySuccessPage-失败-当前不是 首页");
    return false;
};


// 是否为 Send Money Fail 页
const isSendMoneyFailPage = () => {
    let textList = className("TextView").find();
    // console.log(Constant.UI_SDK_VERSION + "判断是否为 Send Money Fail 页-textList ", textList.length)

    let con1 = false;
    let con2 = false;
    let con3 = false;
    let con4 = false;

    for (let index = 0; index < textList.length; index++) {
        let tv = textList[index];
        let curText = tv.text() || ""
        // console.log(Constant.UI_SDK_VERSION + "isSendMoneyFailPage-当前 text: " + index + ", 内容: ", curText)

        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag1) !== -1) {
            con1 = true;
        }
        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag2) !== -1) {
            con2 = true;
        }
        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag3) !== -1) {
            con3 = true;
        }
        if (curText.indexOf(WaveFcfaPageTag.sendMoneyAmounFailPageTag4) !== -1) {
            con4 = true;
        }

        if (con1 && con2 && con3 && con4) {
            console.log(Constant.UI_SDK_VERSION + "isSendMoneyFailPage-当前是 Send Money Fail 页");
            textList.length = 0;
            textList = null;
            return true;
        }
    }

    textList.length = 0;
    textList = null;

    console.log(Constant.UI_SDK_VERSION + "isSendMoneyFailPage-当前不是 Send Money Fail 页");
    return false;
};

// 返回首页-从转账失败页
const doToHomePageFromSendMoneyFailPage = () => {
    back();
    sleep(1000);
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
};

// 返回首页-从转账确认页
const doToHomePageFromSendMoneyAmountInputConfirmPage = () => {
    doToHomePageFromSendMoneyFailPage();
};

// 返回首页-从转账起始页
const doToHomePageFromSendMoneyPage = () => {
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
};

// 返回首页-从转账起始页
const doToHomePageFromSendMoneyAmountInputPage = () => {
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
    click(WaveFcfaPageTag.sendMoneyPageTag1);
    sleep(1000);
};

// 返回首页-从账单详情页
const doToHomePageFromBillDetailPage = () => {
    back();
    sleep(1000);
};

module.exports = {
    // 页面查询操作
    doCheckPageStatus: doCheckPageStatus,
    isLoginPage: isLoginPage,
    doOpenHomePage: doOpenHomePage,
    isHomePage: isHomePage,
    isBillDetailPage: isBillDetailPage,
    isSendMoneyPage: isSendMoneyPage,
    doOpenSendMoneyPage: doOpenSendMoneyPage,
    isSendMoneyAccountInputPage: isSendMoneyAccountInputPage,
    doOpenSendMoneyAccountInputPage: doOpenSendMoneyAccountInputPage,
    isSendMoneyAmountInputPage: isSendMoneyAmountInputPage,
    doOpenSendMoneyAmountInputPage: doOpenSendMoneyAmountInputPage,
    isSendMoneyAmountInputConfirmPage: isSendMoneyAmountInputConfirmPage,
    doOpenSendMoneyAmountInputConfirmPage: doOpenSendMoneyAmountInputConfirmPage,
    findSendMoneyAmountInputConfirmButton: findSendMoneyAmountInputConfirmButton,
    isSendMoneySuccessPage: isSendMoneySuccessPage,
    isSendMoneyFailPage: isSendMoneyFailPage,

    // 返回首页操作
    doToHomePageFromSendMoneyFailPage: doToHomePageFromSendMoneyFailPage,
    doToHomePageFromSendMoneyAmountInputConfirmPage: doToHomePageFromSendMoneyAmountInputConfirmPage,
    doToHomePageFromSendMoneyPage: doToHomePageFromSendMoneyPage,
    doToHomePageFromSendMoneyAmountInputPage: doToHomePageFromSendMoneyAmountInputPage,
    doToHomePageFromBillDetailPage: doToHomePageFromBillDetailPage,

};